package com.swk.version4.bookCity;

import java.util.List;

import org.junit.Test;

import com.swk.version4.base.BaseNovel;
import com.swk.version4.bean.Chapter;
import com.swk.version4.behaviorImpl.ConnectWithoutLogin;
import com.swk.version4.behaviorImpl.HandleListForXxbiquge;
import com.swk.version4.behaviorImpl.HandleTextById;

/**
 * 
 * @author 慎伟康
 * 
 * @date 2018年1月13日 下午11:23:06
 * 
 * @Description
 *    新笔趣阁
 *    https://www.xxbiquge.com/
 */
public class Xxbiquge extends BaseNovel {
	
	/**
	 * 空参构造器，将合适的解析算法组合起来。
	 */
	public Xxbiquge() {
		super();
		setConnectWebPageBehavior(new ConnectWithoutLogin());
		setHandleChapterContentBehavior(new HandleTextById());
		setHandleChapterListBehavior(new HandleListForXxbiquge());
	}
	
	@Test
	public void testList(){//测试获取章节列表方法
//		String url = "https://www.xxbiquge.com/74_74821/";//圣墟
//		String analyzeParam = "/74_74821";
		
//		String url = "https://www.xxbiquge.com/75_75918/";//一念永恒
//		String analyzeParam = "/75_75918";
		
//		String url = "https://www.xxbiquge.com/0_601/";//修仙狂徒
//		String analyzeParam = "/0_601";//https://www.xxbiquge.com/0_601/
		
//		String url = "https://www.xxbiquge.com/76_76270/";//万域之王
//		String analyzeParam = "/76_76270";
		
		String url = "https://www.xxbiquge.com/1_1434/";//飞天
		String analyzeParam = "/1_1434";
		List<Chapter> list = getChapterList(url, analyzeParam);
		for (Chapter chapter : list) {
			System.out.println(chapter.getChapterHref() + "-->" + chapter.getChapterName());
		}
		System.out.println(list.size());
	}
	
	@Test
	public void testText(){//测试获取单章文本方法
//		String url = "https://www.xxbiquge.com/74_74821/4115377.html";//圣墟
//		String url = "https://www.xxbiquge.com/75_75918/4119405.html";//一念永恒
//		String url = "https://www.xxbiquge.com/0_601/5907756.html";//修仙狂徒
//		String url = "https://www.xxbiquge.com/76_76270/86229.html";//万域之王
		String url = "https://www.xxbiquge.com/1_1434/8862781.html";//飞天
		
		String s = getChapterText(url);
		System.out.println(s);
	}
	
	@Test
	public void xiuXianKuangTu(){//修仙狂徒
		String url = "https://www.xxbiquge.com/0_601/";
		String pathname = "src/com/swk/novel/修仙狂徒.txt";
		String analyzeParam = "/0_601";
		downloadAll(url, pathname, analyzeParam);
//		download(url, pathname, 100, analyzeParam);
	}
	
	@Test
	public void shengXu(){//圣墟
		String url = "https://www.xxbiquge.com/74_74821/";
		String pathname = "src/com/swk/novel/圣墟.txt";
		String analyzeParam = "/74_74821";
		download(url, pathname, 100, analyzeParam);
	}
	
	@Test
	public void yiNianYongHeng(){//一念永恒
		String url = "https://www.xxbiquge.com/75_75918/";
		String pathname = "src/com/swk/novel/一念永恒.txt";
		String analyzeParam = "/75_75918";
		download(url, pathname, 100, analyzeParam);
	}
	
	@Test
	public void wanYuZhiWang(){//万域之王
		String url = "https://www.xxbiquge.com/76_76270/";
		String pathname = "src/com/swk/novel/万域之王.txt";
		String analyzeParam = "/76_76270";
		download(url, pathname, 100, analyzeParam);
	}
	
	@Test
	public void feiTian(){//飞天
		String url = "https://www.xxbiquge.com/1_1434/";
		String pathname = "src/com/swk/novel/飞天.txt";
		String analyzeParam = "/1_1434";
		download(url, pathname, 116, analyzeParam);
	}
}
